#!/bin/bash

# 批量修复导入问题的脚本
# 修复所有示例文件中的导入错误

echo "🔧 开始批量修复导入问题..."

# 修复SmartConfigManager -> SmartAgentConfigManager
echo "修复SmartConfigManager导入..."
find src/examples -name "*.cj" -exec sed -i '' 's/SmartConfigManager/SmartAgentConfigManager/g' {} \;

# 修复ProviderConfig -> SmartProviderConfig
echo "修复ProviderConfig导入..."
find src/examples -name "*.cj" -exec sed -i '' 's/ProviderConfig/SmartProviderConfig/g' {} \;

# 修复ConfigError -> SmartConfigError
echo "修复ConfigError导入..."
find src/examples -name "*.cj" -exec sed -i '' 's/ConfigError/SmartConfigError/g' {} \;

# 修复AgentConfigManager -> SmartAgentConfigManager (如果有重复)
echo "修复AgentConfigManager导入..."
find src/examples -name "*.cj" -exec sed -i '' 's/AgentConfigManager/SmartAgentConfigManager/g' {} \;

# 修复createProviderConfig -> createSmartAgent
echo "修复createProviderConfig导入..."
find src/examples -name "*.cj" -exec sed -i '' 's/createProviderConfig/createSmartAgent/g' {} \;

echo "✅ 导入修复完成！"

# 检查修复结果
echo "🔍 检查修复结果..."
echo "剩余的SmartConfigManager引用:"
grep -r "SmartConfigManager" src/examples/ --include="*.cj" | wc -l

echo "剩余的ProviderConfig引用:"
grep -r "ProviderConfig" src/examples/ --include="*.cj" | wc -l

echo "剩余的ConfigError引用:"
grep -r "ConfigError" src/examples/ --include="*.cj" | wc -l

echo "🎯 导入修复脚本执行完成！"
